package ltd.followkba.comment.edit;

import static ltd.advskin.MSKIN.MTOAST;


/**
 * Created by Patrick on 2016/11/12.
 * 登录
 */

//public class ManageLoginActivity extends SkinActivity {
//	private EditText mAccount;
//	private EditText mPassword;
//	private EditText mAuthCode;
//	private Context mContext;
//
//	@Override
//	protected void onCreate(Bundle savedInstanceState)	{
//		super.onCreate(savedInstanceState);
////		setContentView(R.layout.login_layout);
//		setContentView(R.layout.page_login_layout);
//		mContext = this;
//
//		initView();
//		IntentFilter filter = new IntentFilter();
//		filter.addAction(ACTION_KCS_MESSAGE);
//		registerReceiver(mBroadcastReceiver, filter);
//
//		mAccount = (EditText)findViewById(R.id.etAccount);
//		mAccount.setText(MBAPP.RD_PRIVATE_STRING("account", MBAPP.gsMainMem));
//		mPassword = (EditText)findViewById(R.id.etPassword);
//		mPassword.setText(MBAPP.RD_PRIVATE_STRING("password", MBAPP.gsMainMem));
//		mAuthCode = (EditText)findViewById(R.id.etAuthCode);
//
//		ChangAhtoCode();
//
//		Button mBtnAutoCode = (Button)findViewById(R.id.btAuthCode);
//		mBtnAutoCode.setOnClickListener(new View.OnClickListener() {
//			@Override
//			public void onClick(View v) {
//				ChangAhtoCode();
//			}
//		});
//		Button mBtnLogin = (Button)findViewById(R.id.btLogin);
//		mBtnLogin.setOnClickListener(new View.OnClickListener() {
//			@Override
//			public void onClick(View v) {
//				String account = mAccount.getText().toString();
//				if ("".equals(MBAPP.RD_PRIVATE_STRING("account", MBAPP.gsMainMem))){
//					MBAPP.WR_PRIVATE_STRING("account", account, MBAPP.gsMainMem);
//				}
//				if ("".equals(account)){
//					MTOAST("需要输入正确的操作号");
//					return;
//				}
//				String password = mPassword.getText().toString();
//				if ("".equals(MBAPP.RD_PRIVATE_STRING("password", MBAPP.gsMainMem))){
//					MBAPP.WR_PRIVATE_STRING("password", password, MBAPP.gsMainMem);
//				}
//				if ("".equals(password)){
//					MTOAST("需要输入正确的操作密码");
//					return;
//				}
//				String authCode = mAuthCode.getText().toString();
//				if ("".equals(authCode)){
//					MTOAST("需要输入正确的验证码");
//					return;
//				}
//				MTOAST(String.format("操作号%s正在登录，请稍候", account));
////				MBAPP.mSvrManage.loginSvr(account, password, authCode, new ServiceHandler() {
////					@Override
////					public void onComplete(ServiceState state, String extraMessage) {
////MBAPP.MSTRING("登录完成 "+state);
////						if (state == ServiceState.SUCCEED) {
////							MAPI.WR_PRIVATE_STRING("account", mAccount.getText().toString(), MBAPP.gsMainMem);
////							MAPI.WR_PRIVATE_STRING("password", mPassword.getText().toString(), MBAPP.gsMainMem);
////							MBAPP.gLoginStatus = LOGIN_GET_INFO;
////
////							finish();
//////							MBAPP.mSvrManage.getCurrentManager(new ManagerService.GetCurrentManagerHandler() {
//////								@Override
//////								public void onComplete(ServiceState state, String extraMessage, Manager manager) {
//////									if (state == ServiceState.SUCCEED) {
//////										MBAPP.mManager = manager;
//////										MBAPP.gStartUp = 1;
//////									}
//////									else {
//////										MTOAST("获取信息出错：" + extraMessage);
//////									}
//////								}
//////							});
////						}
////						else {
////							MTOAST("登录出错：" + extraMessage);
////						}
////					}
////				});
//			}
//		});
//	}
//
//	private void initView()	{
//		View btForgetPasswordView = findViewById(R.id.btForgetPasswordView);
//		btForgetPasswordView.setOnClickListener(onClickListener);
//		View btRegistrationAdministratorView = findViewById(R.id.btRegistrationAdministratorView);
//		btRegistrationAdministratorView.setOnClickListener(onClickListener);
//		findViewById(R.id.ivPublicReturn).setOnClickListener(onClickListener);
//	}
//
//	View.OnClickListener onClickListener = new View.OnClickListener()
//	{
//		@Override
//		public void onClick(View view)
//		{
//
//			switch (view.getId())			{
//			case R.id.btForgetPasswordView:
//			{
////				Intent intent = new Intent(ManageLoginActivity.this, ForgetPasswordActivity.class);
////				ManageLoginActivity.this.startActivity(intent);
//			}
//				break;
//			case R.id.btRegistrationAdministratorView:			{
////				Intent intent = new Intent(ManageLoginActivity.this, RegistrationAdministratorActivity.class);
////				ManageLoginActivity.this.startActivity(intent);
//			}
//				break;
//			case R.id.ivPublicReturn:
//			{
////				MBAPP.g4PowerOnTimer = 1;
////				finish();
//			}
//				break;
//			}
//
//		}
//	};
//	private void ChangAhtoCode(){
////		MSTRING("ChangAhtoCode");
////		MBAPP.mSvrTools.getAuthCode(new ToolsService.GetImgFileHandler() {
////			@Override
////			public void onComplete(ServiceState state, String extraMessage, String imgFile) {
////				MBAPP.MSTRING("MBAPP.mSvrTools.getAuthCode:" + imgFile);
////				ImageView mImageView = (ImageView)findViewById(R.id.ivAuthCode);
////				Drawable mDrawable = BitmapDrawable.createFromPath(imgFile);
////				mImageView.setImageDrawable(mDrawable);
////			}
////		});
//	}
//
//
//	private String gsSaveString;
//	AlertDialog.Builder mBuilder = null;
//
//	@Override
//	protected void onDestroy() {
//		super.onDestroy();
//		unregisterReceiver(mBroadcastReceiver);
//	}
//	private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
//		@Override
//		public void onReceive(Context context, Intent intent) {
//MSTRING("BroadcastReceiver ");
//			if (intent != null){
//				String action = intent.getAction();
//				if (ACTION_KCS_MESSAGE.equals(action)){
//					int type = intent.getIntExtra(EXTRA_KCS_MESSAGE_TYPE, 0);
//					int g4Local_1 = intent.getIntExtra(EXTRA_INT_PARAMETER, 0);
//					String gsLocal_1 = intent.getStringExtra(EXTRA_STRING_PARAMETER1);
//					gsSaveString = intent.getStringExtra(EXTRA_STRING_PARAMETER2);
//MSTRING("BroadcastReceiver "+type+" "+gsLocal_1+" "+gsSaveString);
////					switch (type) {
////						case SYSTEM_SYS_FILE_EXE0:            // 有不同版本的升级文件
////							MDialogShow(type, gsLocal_1);
////							break;
////						case SYSTEM_SYS_FILE_EXE1:            // 替换升级文件
////							MDialogShow(type, gsLocal_1);
////							break;
////					}
//				}
//			}
//		}
//	};
//	private void MDialogShow(int type, String gsLocal_1){
//		if (mBuilder == null){
//			mBuilder = new AlertDialog.Builder(ManageLoginActivity.this);
//			mBuilder.setTitle("提示");
//
//
//			mBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
//				@Override
//				public void onClick(DialogInterface dialog, int which) {
//
////					MInstallApkFile(mContext, MRAM.gsDownloadPath + gsSaveString);
//					mBuilder = null;
//
//				}
//			});
//			mBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
//				@Override
//				public void onClick(DialogInterface dialog, int which) {
//					mBuilder = null;
//				}
//			});
//			mBuilder.setMessage(gsLocal_1);
//			AlertDialog dialog = mBuilder.create();
//			dialog.show();
//		}
//	}
//	private void MInstallApkFile(Context context, String filePath) {
//		MSTRING("准备升级文件" + filePath);
//		Intent intent = new Intent(Intent.ACTION_VIEW);
//		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
//			intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
//			Uri contentUri = FileProvider.getUriForFile(context, "com.FollowKBa.fileprovider", new File(filePath));
//			intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
//		} else {
//			intent.setDataAndType(Uri.fromFile(new File(filePath)), "application/vnd.android.package-archive");
//			intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//		}
//		context.startActivity(intent);
//	}
////	private void MInstallApkFile(String gsLocal_1) {
////		File apkFile = new File(gsLocal_1);
////MBAPP.MSTRING("准备升级文件" + gsLocal_1 + " "+MAPI.GET_FILE_LENGTH(gsLocal_1));
////		if (MAPI.GET_FILE_LENGTH(gsLocal_1) > 1000000) {
////
////			Intent intent = new Intent();
////			intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
////			intent.setAction(android.content.Intent.ACTION_VIEW);
////			intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
////			startActivity(intent);
////		}
////	}
//
//
//}
